package org.example.deep.dao;

import org.example.deep.entity.ElecAnalyseRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ElecAnalyseRecordRepository extends JpaRepository<ElecAnalyseRecord, Long> {
    @Query(nativeQuery = true, value = "select SEQ_ELEC_ANALYSE_RECORD.nextval from dual")
    long findSeq();

    @Query(nativeQuery = true, value = "select data_type, sum(DATA_NUM) num from (select id, decode(DATA_TYPE, 1, 1, 2, 1, 3, 1, 4, 2, 5, 2, 6, 2,7,1,8,2) data_type, DATA_NUM from ELEC_ANALYSE_RECORD) group by data_type")
    List<Map<String, Integer>> countByType();
}